package coroutines

import kotlinx.coroutines.*
import java.lang.AssertionError

fun main(){
    runBlocking {
        try {
            supervisorScope {
                val child = launch {
                    try {
                        println("The child is sleeping")
                        delay(Long.MAX_VALUE)
                    }finally {
                        println("The child is cancelled")
                    }
                }
                yield()
                println("Throwing an exception from the scope")
                throw AssertionError()
            }
        }catch (e : AssertionError){
            println("caught as assettion error")
        }
    }
}